from core.support import set_cutscene
from core.item import Item
from core.action import Action
from items.earing import Earing
from items.sunglasses import Sunglasses
from items.sunglassrig import Sunglassrig
from items.earingrig import Earingrig
from core.game import Game
import logging

class Kite(Item):
    def __init__(self):
        Item.__init__(self, "kite")    # do basic initialization for every item
        # build list of actions
        self.add_action(UseKite)
    
    def get_description(self):
        return "Kite"

# define actions for this item

class UseKite(Action):
    def __init__(self):
        Action.__init__(self, "kite")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Use Kite"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        player = game.get_player()
        logging.info("player.inventory ---------------------------------########")
        logging.info(player.inventory)
        logging.info("....room.get_id() ....")
        logging.info(room.get_id())
        if room.get_id() == 'sea6fishing':
                if 'sunglasses' in player.inventory:
                    #room.add_item(Sunglassrig())
                    player.add_item(Sunglassrig())
                    player.pop_item('sunglasses')
                    player.pop_item('kite')
                    set_cutscene("You've constructed a makeshift fishing device.")
                elif 'earing' in player.inventory:
                    player.add_item(Earingrig())
                    player.pop_item('earing')
                    player.pop_item('kite')
                    set_cutscene("You've constructed a makeshift fishing device.")
                else:
                    set_cutscene("If only I had something to make tackle out of")
        else:
            set_cutscene("There's nothing to use the kite for here.")
        return